//参数
    var typeid = getQueryString("typeid");
    var pageIndex = 0;
    var pageSize = 12;
    var allPage = 0;
    var typeArray = [];
    $(function () {
        getTopHtml(2);//网站顶部
        //获取banner
        getPageBannerImg(2);
        $(".con_img_box").css({ "height": "729px" });
        //显示类别
        getTypeList();
        tab_pro_top();
        //默认显示
        BindData();
        $(window).resize(function () {
            setauto();
        });
        $(window).scroll(function () {
            tab_pro_top();
        });
    });
    function tab_pro_top() {
        var scroH = document.documentElement.scrollTop || window.pageYOffset || document.body.scrollTop;
        if (scroH >= 848) {
            $(".public_tab_pro").attr("style", "position:fixed;top:0px;left:0px;z-index:200;");
            //$(".publictab_line2").show();
        }
        else {
            $(".public_tab_pro").attr("style", "position:absolute;bottom:0px;left:0px;z-index:200;");
            //$(".publictab_line2").hide();
        }
    }
    //图片高度计算
    function setauto() {
        var wh = ($("#ConProList").width() / 4) - 32;
        var hi = (wh * 248) / 337;
        $(".product-item").css({ "width": wh + "px", "height": hi + "px" });
    }
    //选项卡切换
    function changenav1(id) {
        $(".tab_items a").removeClass("on");
        $("#tnavid" + id).addClass("on");
        $(".pro_type_img").children("img").hide();
        $(".pro_type_img").children("#protypeimg" + id).show();
        $.each(typeArray, function (y, x) {
            if (id == x.Id) {
                getChirldNav(x.ChirldProductType);
            }
        });
        pageIndex = 0;
        BindData();
    }
    //二级类型
    function changenav2(id) {
        $(".products-style li").removeClass("active-style");
        $("#enavid" + id).addClass("active-style");
        pageIndex = 0;
        BindData();
    }
    //获取类别
    function getTypeList() {
        $.zmdAjax("ProductTypeList", "POST", { LanguageType: LanguageId }, false, function (obj) {
            if (obj.code == 0) {
                if (obj.count > 0) {
                    typeArray = obj.data;
                    $.each(obj.data, function (i, e) {
                        var str = "";
                        $(".pro_type_img").append('<img src="' + e.BigImgUrl + '" id="protypeimg' + e.Id + '" />');
                        if (typeid == e.Id) {
                            $(".pro_type_img").children("#protypeimg" + e.Id).show();
                            if (e.IsLink == 1) {
                                str += '<a class="on" href="' + e.LinkAddress + '" ids="" target="_blank">' + e.Name + '<div class="ico"></div></a>';
                            }
                            else {
                                str += '<a class="on" id="tnavid' + e.Id + '" onclick="changenav1(' + e.Id + ')" ids="' + e.Id + '">' + e.Name + '<div class="ico"></div></a>';
                            }
                            getChirldNav(e.ChirldProductType);
                        }
                        else {
                            if (typeid == "-1") {
                                if (i == 0) {
                                    $(".pro_type_img").children("#protypeimg" + e.Id).show();
                                    if (e.IsLink==1) {
                                        str += '<a class="on" href="' + e.LinkAddress + '" ids="" target="_blank">' + e.Name + '<div class="ico"></div></a>';
                                    } else {
                                        str += '<a class="on" id="tnavid' + e.Id + '" onclick="changenav1(' + e.Id + ')" ids="' + e.Id + '">' + e.Name + '<div class="ico"></div></a>';
                                    }
                                    getChirldNav(e.ChirldProductType);
                                }
                                else {
                                    if (e.IsLink == 1) {
                                        str += '<a href="' + e.LinkAddress + '" ids="" target="_blank">' + e.Name + '<div class="ico"></div></a>';
                                    } else {
                                        str += '<a id="tnavid' + e.Id + '" onclick="changenav1(' + e.Id + ')" ids="' + e.Id + '">' + e.Name + '<div class="ico"></div></a>';
                                    }
                                }
                            }
                            else {
                                if (e.IsLink == 1) {
                                    str += '<a href="' + e.LinkAddress + '" ids="" target="_blank">' + e.Name + '<div class="ico"></div></a>';
                                } else {
                                    str += '<a id="tnavid' + e.Id + '" onclick="changenav1(' + e.Id + ')" ids="' + e.Id + '">' + e.Name + '<div class="ico"></div></a>';
                                }
                            }
                        }
                        $("#pro_nav1_list").append(str);
                    });
                    $("#pro_nav1_list").append('<div class="clear"></div>');
                }
            }
            else {
                getErrorMsg(obj.message);//错误提示
            }
        }, function (obj) {
            getErrorMsg(obj.message);//错误提示
        });
    }
    //循环二级类型
    function getChirldNav(cdata) {
        var str = "";
        $.each(cdata, function (n, m) {
            if (n == 0) {
                if (m.IsLink == 1) {
                    str += '<li class="active-style" href="' + m.LinkAddress + '" ids="" target="_blank">' + m.Name + '</li>';
                } else {
                    str += '<li id="enavid' + m.Id + '" ids="' + m.Id + '" class="active-style" onclick="changenav2(' + m.Id + ')">' + m.Name + '</li>';
                }
            }
            else {
                if (m.IsLink == 1) {
                    str += '<li href="' + m.LinkAddress + '" ids="" target="_blank">' + m.Name + '</li>';
                } else {
                    str += '<li id="enavid' + m.Id + '" ids="' + m.Id + '" onclick="changenav2(' + m.Id + ')">' + m.Name + '</li>';
                }
            }
        });
        $("#pro_nav2_list").html(str);
    }
    //获取数据
    var ind = 0;
    function BindData() {
        if (pageIndex == 0) {
            $("#ConProList").html("");
            ind = 0;
        }
        var tid = $("#pro_nav2_list .active-style").attr("ids");
        if (tid == undefined) {
            tid = $(".tab_items a.on").attr("ids");
        }
        if (tid == "") {
            tid = -1;
        }
        var datas = { LanguageType: LanguageId, ProductTypeId: tid, PageIndex: pageIndex, PageSize: pageSize };
        $.zmdAjax("ProductList", "POST", datas, false, function (obj) {
            if (obj.code == 0) {
                if (obj.count > 0) {
                    if ((obj.count % pageSize) > 0) {
                        allPage = parseInt(obj.count / pageSize) + 1;
                    }
                    else {
                        allPage = parseInt(obj.count / pageSize);
                    }
                    if (allPage == (pageIndex + 1)) {
                        getPagerMsg();//暂无数据
                    } else {
                        getPagerBtn();//分页
                    }
                }
                else {
                    getPagerMsg();//暂无数据
                }
                var str = "";
                $.each(obj.data, function (i, e) {
                    str += '<div class="product-item" style="margin:0px 16px 32px;">';
                    str += '<img src="' + e.BigImgUrl + '" alt="">';
                    str += '<div class="mask-products">';
                    str += '<div class="mask-title">';
                    //str += '<span class="msk-l">ㅡ</span>';
                    //str +=' <span class="mas-tit-na">' + e.Name + '</span>';
                    //str += ' <span class="msk-l">ㅡ</span>';
                    str += '</div>';
                    str += '<div class="mask-btn hover" onclick="lookproimg(' + ind + ')">查看大图</div>';
                    str += '</div>';
                    str += '</div>';
                    ind++;
                });
                $("#ConProList").append(str);
                setauto();//计算容器高度
            }
            else {
                getErrorMsg(obj.message);//错误提示
            }
        }, function (obj) {
            getErrorMsg(obj.message);//错误提示
        });
    }
    //点击加载更多
    function BindNext() {
        pageIndex++;
        BindData();
    }

    //查看大图
    function lookproimg(ind) {
        var swtr = "";
        swtr += '<div class="anti_search" id="pro_center">';
        if (document.documentElement.clientHeight <= 770) {
            swtr += '<div class="anti_box product" id="SwiperProShow" style="width:800px;height:590px;left:' + ((document.documentElement.clientWidth / 2) - 410) + "px" + ';top:' + ((document.documentElement.clientHeight / 2) - 305) + "px" + ';">';
        } else {
            swtr += '<div class="anti_box product" id="SwiperProShow" style="left:' + ((document.documentElement.clientWidth / 2) - 528) + "px" + ';top:' + ((document.documentElement.clientHeight / 2) - 367) + "px" + ';">';
        }
        swtr += '<div class="bd" id="HomeTopBanner">';
        $("#ConProList .product-item").each(function (s) {
            swtr += '<div class="slide_li"><img src="' + $(this).children("img").attr("src") + '" alt="" /></div>';
        });
        swtr += '</div>';
        if (document.documentElement.clientHeight <= 770) {
            swtr += '<a class="sPrev" style="top:263px;"></a>';
            swtr += '<a class="sNext" style="top:263px;"></a>';
        }
        else {
            swtr += '<a class="sPrev"></a>';
            swtr += '<a class="sNext"></a>';
        }
        swtr += '<div class="closeico hover" onclick="close_anti(this)"></div>';

        swtr += '<div class="ptxt" style="background:rgba(0, 0, 0, 0.4) url(../img/logo_product.png) no-repeat center center;"></div>';
        swtr += '</div></div>';
        $("body").append(swtr);
        if (document.documentElement.clientHeight <= 770) {
            $(".anti_box .closeico").css({ "top": ((document.documentElement.clientHeight / 2) - 325) + "px", "right": ((document.documentElement.clientWidth / 2) - 428) + "px" });
        }
        else {
            $(".anti_box .closeico").css({ "top": ((document.documentElement.clientHeight / 2) - 384) + "px", "right": ((document.documentElement.clientWidth / 2) - 477) + "px" });
        }
        jQuery("#SwiperProShow").slide({ effect: "left", defaultPlay: false, prevCell: ".sPrev", nextCell: ".sNext", defaultIndex: ind, pnLoop: false });
    }